package com.android.publicModule.model.shortcut;

import android.content.Context;
import android.content.Intent;
import android.content.Intent.ShortcutIconResource;
import android.graphics.drawable.BitmapDrawable;
import android.os.Parcelable;

public class ShortCutManage {
	
	private Context mContext;
	
	public ShortCutManage(Context context) {
		mContext = context.getApplicationContext();
	}
	
	public void createShortCut(String name,boolean duplicate,Intent intent,Parcelable iconRes) {
		Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
		shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
		shortcut.putExtra("duplicate", duplicate);
		shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
		if(iconRes!=null)
		{
			shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
		}
		try {
			mContext.sendBroadcast(shortcut);
		} catch(Exception e) {
			
		}
	}
	
	public void createShortCut(String name,boolean duplicate,Intent intent,int resourceId) {
		ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(mContext, resourceId);
		createShortCut(name,duplicate,intent,iconRes);
	}
	
	public void createShortCut(String name,boolean duplicate,Intent intent,String url) {
		BitmapDrawable sbc;
	}

}
